<#macro html>
<@page.html title="${workflowType.chName}">
<script type="text/javascript" src="${_appPath!}/js/cal.js"></script>
<script type="text/javascript">
  function add() {
    var fm = getEl("fm_input");
    post(fm);
  }
  function getmbc(c) {
    if(c!="") {
      getJson("getContract?code="+c, function(data){
        if(data.ret) {
          var mc = data.data;
          var fm = getEl("fm_input");
          fm.contractCode.value = mc.contractCode;
          fm.saleDate.value = getDateStr(new Date(mc.saleDate));
          fm.saleType.value = mc.saleType+" - "+mc.saleTypeName;
          fm.memberCode.value = mc.memberCode;
          fm.memberName.value = mc.memberName;
          fm.contractType.value = mc.cardType+" - "+mc.cardTypeName;
          fm.contractBegin.value = getDateStr(new Date(mc.beginTime));
          fm.contractEnd.value = getDateStr(new Date(mc.endTime));
          fm.factAmount.value = formatMoney(mc.factPrice);
          fm.earnestAmount.value = formatMoney(mc.earnestAmount);
          fm.inAmount.value = formatMoney(mc.inAmount);
          fm.payAmount.value = formatMoney(mc.payAmount);
          fillData(mc);
        } else {
          window.alert(data.msg);
          clmbc();
        }
      });
    }
  }
  function clmbc() {
    var fm = getEl("fm_input");
    //fm.contractCode.value = "";
    fm.saleDate.value = "";
    fm.saleType.value = "";
    fm.memberCode.value = "";
    fm.memberName.value = "";
    fm.contractType.value = "";
    fm.contractBegin.value = "";
    fm.contractEnd.value = "";
    fm.factAmount.value = "";
    fm.earnestAmount.value = "";
    fm.inAmount.value = "";
    fm.payAmount.value = "";
    clearData();
  }

  function getptc(c) {
    if(c!="") {
      getJson("getPtContract?code="+c, function(data){
        if(data.ret) {
          var mc = data.data;
          var fm = getEl("fm_input");
          fm.contractCode.value = mc.contractCode;
          fm.saleDate.value = getDateStr(new Date(mc.saleDate));
          fm.saleType.value = mc.saleType+" - "+mc.saleTypeName;
          fm.memberCode.value = mc.memberCode;
          fm.memberName.value = mc.memberName;
          fm.contractItem.value = mc.ptCode+" - "+mc.ptCodeName;
          fm.contractCoach.value = mc.coachCode+" - "+mc.coachName;
          fm.contractBegin.value = getDateStr(new Date(mc.beginTime));
          fm.contractEnd.value = getDateStr(new Date(mc.endTime));
          fm.factAmount.value = formatMoney(mc.factPrice);
          fm.payAmount.value = formatMoney(mc.payAmount);
          fm.contractQuantity.value = mc.quantity;
          fm.bespeakQuantity.value = mc.bespeakQuantity;
          fm.clearQuantity.value = mc.clearQuantity;
          fm.leftQuantity.value = mc.leftQuantity;
          fillData(mc);
        } else {
          window.alert(data.msg);
          clptc();
        }
      });
    }
  }
  function clptc() {
    var fm = getEl("fm_input");
    //fm.contractCode.value = "";
    fm.saleDate.value = "";
    fm.saleType.value = "";
    fm.memberCode.value = "";
    fm.memberName.value = "";
    fm.contractItem.value = "";
    fm.contractCoach.value = "";
    fm.contractBegin.value = "";
    fm.contractEnd.value = "";
    fm.factAmount.value = "";
    fm.payAmount.value = "";
    fm.contractQuantity.value = "";
    fm.bespeakQuantity.value = "";
    fm.clearQuantity.value = "";
    fm.leftQuantity.value = "";
    clearData();
  }

  function fillData(mc) {

  }
  function clearData() {

  }

  function getSales(c) {
    if(c=="") {
      getEl("sp_salesName").innerHTML = "";
    } else {
      getJson("getSales?code="+c, function(data){
        if(data.ret) {
          getEl("ip_salesCode").innerHTML = data.data.code;
          getEl("sp_salesName").innerHTML = data.data.name;
        } else {
          window.alert(data.msg);
          getEl("sp_salesName").innerHTML = "";
        }
      });
    }
  }

</script>
<div style="width:600px;">

  <form id="fm_input" method="post" action="_add" onsubmit="return post(this);">
    <input type="hidden" name="typeId" value="${workflowType.code}">
    <div class="kbox">
      <table class="input w4">
        <#nested/>
        <tr>
          <th>申请原因</th>
          <td colspan="3"><textarea name="note"></textarea></td>
        </tr>
      </table>
    </div>
    <div class="button"><input type="button" value="保存申请" onclick="add();"></div>
  </form>
</div>
</@page.html>
</#macro>